package com.wencun.cunpicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wencun.cunpicturebackend.model.dto.user.UserQueryRequest;
import com.wencun.cunpicturebackend.model.dto.user.UserRegisterRequest;
import com.wencun.cunpicturebackend.model.entity.User;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wencun.cunpicturebackend.model.vo.LoginUserVO;
import com.wencun.cunpicturebackend.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
* @author 温存
* @description 针对表【user(用户)】的数据库操作Service
* @createDate 2025-08-17 22:00:13
*/
public interface UserService extends IService<User> {
    /**
     * @description 用户注册
     * @param userRegisterRequest
     * @return long
     * @time 2025-08-18 16:07
     */
    long userRegister(UserRegisterRequest userRegisterRequest);

    /**
     * @description 获取加密后的密码
     * @param userPassword 密码
     * @return String 加密后的密码
     * @time 2025-08-18 15:05
     */
    String getEncryptPassword(String userPassword);

    /**
     * @description 用户登录
     * @param userAccount
     * @param userPassword
     * @param request
     * @return LoginUserVO
     * @time 2025-08-18 15:45
     */
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request);

    /**
     * @description 获取登录用户（系统内部使用，不返回给前端）
     * @param request
     * @return User
     * @time 2025-08-18 16:12
     */
    User getLoginUser(HttpServletRequest request);


    /**
     * @description 获取登录用户VO
     * @param user
     * @return LoginUserVO
     * @time 2025-08-18 15:46
     */
    LoginUserVO getLoginUserVO(User user);


    /**
     * @description 用户注销
     * @param request
     * @return boolean
     * @time 2025-08-18 16:22
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * @description 获得脱敏后的用户信息
     * @param user
     * @return UserVO
     * @time 2025-08-18 20:07
     */
    UserVO getUserVO(User user);

    /**
     * @description 获得脱敏后的用户信息列表
     * @param userList
     * @return List<UserVO>
     * @time 2025-08-18 20:09
     */
    List<UserVO> getUserVOList(List<User> userList);


    /**
     * @description 获取查询条件
     * @param userQueryRequest
     * @return QueryWrapper<User>
     * @time 2025-08-18 20:18
     */
    QueryWrapper<User> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(User user);

}
